<script setup lang="ts">
import type { IColumnConfig, ITableObj, ITableProp } from '@/type/interfaces'

interface IProps {
  tableProp?: ITableProp
  tableObj: ITableObj
}
const props = withDefaults(defineProps<IProps>(),{
    tableProp: () => {
    return {
      width: '100%',
      stripe: true,
      size: '',
    }
  }
})
</script>
<template>
    <el-table :data="tableObj.data" :style="{ width: tableProp.width }" size="small" v-bind="$attrs">
      <el-table-column type="index" fixed="left" label="行" />
      <el-table-column v-for="(item, index) in tableObj.columnConfig" :key="index" :column-key="index"
        :label="item.name" :width="item.width">
        <template #default="scope">
          <slot :name="item.prop" :index="scope.$index" :row="scope.row">
            {{ scope.row[item.prop] }}
        </slot>
        </template>
    </el-table-column>
      <el-table-column label="action" :width="tableProp.actionWidth" fixed="right">
        <template #default="scope">
          <slot name="rowAction" :index="scope.$index" :row="scope.row"></slot>
        </template>
      </el-table-column>
    </el-table>
</template>
